<template>
	<view class="wpprs">
		<scroll-view scroll-x class="top">
			<view class="btn" @click="acw = 0">
				<view class="text">用户手册</view>
				<view class="xian" :class="acw == 0 ? 'acw' : ''"></view>
			</view>
			<view class="btn" @click="acw = 1">
				<view class="text">注意事项</view>
				<view class="xian" :class="acw == 1 ? 'acw' : ''"></view>
			</view>
			<view class="btn" @click="acw = 2">
				<view class="text">产品资料</view>
				<view class="xian" :class="acw == 2 ? 'acw' : ''"></view>
			</view>
			<view class="btn" @click="acw = 3">
				<view class="text">安装准备</view>
				<view class="xian" :class="acw == 3 ? 'acw' : ''"></view>
			</view>
			<view class="btn" @click="acw = 4">
				<view class="text">常见问题</view>
				<view class="xian" :class="acw == 4 ? 'acw' : ''"></view>
			</view>
		</scroll-view>
		<view class="pdfbox">
			<scroll-view scroll-y class="listbox">
				<view class="list" v-for="(item, idx) in dataCategoryList[acw].dataDTOList" :key="idx" @click="toPdf(item)">
					<view>{{ item.name }}</view>
					<view class="r">{{ '>' }}</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import { dataCategory } from '../../api/order.js';
export default {
	data() {
		return {
			acw: 0,
			dataCategoryList: []
		};
	},
	onLoad() {
		dataCategory().then((data) => {
			this.dataCategoryList = data.content.list;
		});
	},
	methods: {
		toPdf(val) {
			uni.showLoading({
				title: '正在加载'
			});
			uni.downloadFile({
				url: JSON.parse(val.resource)[0].url,
				success: function (res) {
					var filePath = res.tempFilePath;
					uni.openDocument({
						filePath: filePath,
						showMenu: true,
						success: function (res) {
							console.log('打开文档成功');
							uni.hideLoading();
						}
					});
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
.wpprs {
	position: fixed;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
	background-color: #f1f1f1;
	.top {
		background-color: #fff;
		border-radius: 0 0 10upx 10upx;
		width: 100%;
		white-space: nowrap;
		.btn {
			width: 25%;
			display: inline-block;
			text-align: center;
			line-height: 1;
			padding: 20upx 0;
			.xian {
				width: 60upx;
				height: 4upx;
				background-color: #fff;
				display: inline-block;
				border-radius: 4upx;
			}
			.acw {
				width: 60upx;
				height: 4upx;
				background-color: red;
				display: inline-block;
				border-radius: 4upx;
			}
		}
	}
	.pdfbox {
		height: calc(100% - 200upx);
		width: 100%;
		padding: 30upx;
		box-sizing: border-box;
		.listbox {
			width: 100%;
			height: 100%;
			background-color: #fff;
			border-radius: 10upx;
			.list {
				padding: 20upx 30upx;
				border-bottom: 1px #eee solid;
				position: relative;
				.r {
					color: #ccc;
					position: absolute;
					right: 30upx;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}
	}
}
</style>
